<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {

    public function _initialize(){
         $qrcode=M("image")->where("id > 8")->getField("id,image,address");//获取二维码
         $this->assign('qrcode',$qrcode);
         $base=M('config')->where(array('id'=>1))->find();//获取配置参数
         C($base);
         $link=M('blogroll')->where(array('state'=>1))->select();
          $this->assign('link',$link);
    }
  
    public function index(){
        $realname=$_SESSION['user']['realname'];
        $m1=M('Event');//举报
       
        $m2=M('Case');//资讯

        $m3=M('News');//案例

        $m4=M('Config');

        $m5=M('image');
        // $count=$Report->count();
        // $Page= new \Think\Page($count,10);
        // $show=$Page->show();
        $Report=$m1->where(array('state'=>1,'type'=>1))->order('id desc')->limit(5)->getField('id,title,addtime,bereport');

        $Praise=$m1->where(array('state'=>1,'type'=>2))->order('id desc')->limit(5)->getField('id,title,addtime,bereport');

        $Case=$m2->order('id desc')->limit(6)->getField('id,title,addtime,image');//将获取的第一个键值为索引

        $News=$m3->order('id desc')->limit(3)->getField('id,title,addtime,image,abstract');

        $Config=$m4->where(array('id'=>1))->find();//获取配置

        $Image=$m5->where(array('is_see'=>1))->where("id < 9")->getField('id,image,address');

        $keyword=explode(',',$Config['hotword']);

        $Case=array_values($Case);//清空键值重新赋值
        $Image=array_values($Image);
        $this->assign('report',$Report);
        $this->assign('praise',$Praise);
        $this->assign('case',$Case);
        $this->assign('news',$News);
        $this->assign('keyword',$keyword);
        $this->assign('realname',$realname);
        $this->assign('image',$Image);
        $this->display();
    }

    // public function login(){
    //     $this->display();
    // }
    public function Protocol(){
        $this->display();
    }
    public function Protocol_user(){
        $this->display();
    }
}